<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-enter-edit">
			<input name="id"  type="hidden"  th:field="*{enterForm.id}" />
			<h4>编辑订单信息</h4>
			<br>
			<hr>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单编号：</label>
						<div class="col-sm-8">
							<input class="form-control" placeholder="请输入订单编号" type="text" name="formNum" id="formNum" required th:field="*{enterForm.formNum}">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>旺旺号：</label>
						<div class="col-sm-8">
							<input class="form-control" placeholder="请输入旺旺号" type="text" name="wwNum" id="wwNum" required th:field="*{enterForm.wwNum}">
							<input class="form-control"  type="hidden" name="customerColor" id="customerColor" th:field="*{enterForm.customerColor}">

						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>平台：</label>
						<div class="col-sm-8">
							<select class="form-control" name="enterDeptId" id ="enterDeptId" th:field="*{enterForm.enterDeptId}" >
								<option th:each="g : ${deptList}"
										th:selected="${g.deptId eq enterForm.enterDeptId }"
										th:value="${g.deptId}" th:text="${g.deptName}">
								</option>
							</select>
						</div>
					</div>
				</div>

				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>店铺：</label>
						<div class="col-sm-8">
							<select class="form-control" name="enterShopId" id ="enterShopId" th:field="*{enterForm.enterShopId}" >
								<option th:each="g : ${shopList}"
										th:selected="${g.id eq enterForm.enterShopId }"
										th:value="${g.id}" th:text="${g.shopName}">
								</option>
							</select>
						</div>
					</div>
				</div>

				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>产品名称：</label>
						<div class="col-sm-8">
							<select class="form-control" name="enterProductId" id ="enterProductId" th:field="*{enterForm.enterProductId}" >
								<option th:each="g : ${productList}"
										th:selected="${g.id eq enterForm.enterProductId }"
										th:value="${g.id}" th:text="${g.productName}">
								</option>
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
						<div class="form-group">
							<label class="col-sm-4 control-label"><span style="color: red; ">*</span>佣金：</label>
							<div class="col-sm-8">
								<input class="form-control" placeholder="请输入佣金" type="number" name="commission" id="commission" required th:field="*{enterForm.commission}">
							</div>
						</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>微信号：</label>
						<div class="col-sm-8">
							<input class="form-control" placeholder="请输入微信号" type="text" name="webChatNum" id="webChatNum" required th:field="*{enterForm.webChatNum}">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">好评：</label>
						<div class="col-sm-8">
							<input class="form-control" placeholder="请输入好评" type="text" name="goodRecord" id="goodRecord" th:field="*{enterForm.goodRecord}">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单性质：</label>
						<div class="col-sm-8">
							<label class="radio-inline"> <input th:field="*{enterForm.formNature}" type="radio" name="formNature" value="1" />新客户</label>
							<label class="radio-inline"> <input th:field="*{enterForm.formNature}" type="radio" name="formNature" value="2" />老客户</label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">

				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单金额：</label>
						<div class="col-sm-8">
							<input class="form-control" placeholder="请输入订单金额" type="number" name="orderPrice" id="orderPrice" required th:field="*{enterForm.orderPrice}">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">好评单价：</label>
						<div class="col-sm-8">
							<input class="form-control" placeholder="请输入好评单价" type="number" name="goodPrice" id="goodPrice"  th:field="*{enterForm.goodPrice}">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单时间：</label>
						<div class="col-sm-8">
							<!--<input class="form-control" data-datetime="yyyy-mm-dd hh:mm:ss"  type="text" name="createDate" id="createDate" required>-->
							<input style="height: 30px" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss" type="text" class="time-input" id="createDate" name="createDate" onload="getlocalTime()" th:field="*{enterForm.createDate}"/>
						</div>
					</div>
				</div>

			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">备注：</label>
						<div class="col-xs-10">
							<textarea id="remark" name="remark" autocomplete="off" maxlength="500" class="form-control" rows="3" th:field="*{enterForm.remark}"></textarea>
						</div>
					</div>
				</div>
			</div>
			<br>
			<hr>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
	<script type="text/javascript">
		var prefix = ctx + "enter/enter";

        // $("#enterDeptId").on('change',function(){
        //     var deptId = $(this).val();
        //     //查询城市
        //     $.ajax({
        //         type: "GET",
        //         url: prefix +'/allProduct',
        //         async: false,
        //         data:{"deptId":deptId},
        //         contentType : 'application/json;charset=utf-8',
        //         traditional:true,
        //         success : function(data) {
        //             $("#enterProductId").empty();
        //             for(var i=0;i<data.length;i++){
        //                 var html = "<option value='"+data[i].id+"'>"+data[i].productName + "</opinion>"
        //                 $("#enterProductId").append(html);
        //             }
        //         },
        //         error:function(e) {
        //             console.info(e);
        //         }
        //     });
        // });
        $("#enterDeptId").on('change',function(){
            var deptId = $(this).val();
            $.ajax({
                type: "GET",
                url: prefix +'/allShop',
                async: false,
                data:{"deptId":deptId},
                contentType : 'application/json;charset=utf-8',
                traditional:true,
                success : function(data) {

                    $("#enterShopId").empty().append("<option value=''>请选择店铺</opinion>");
                    for(var i=0;i<data.length;i++){
                        var html = "<option value='"+data[i].productShopId+"'>"+data[i].shopName + "</opinion>"
                        $("#enterShopId").append(html);
                    }
                },
                error:function(e) {
                    console.info(e);
                }
            });
        })

        $("#enterShopId").on('change',function(){
            var shopId = $(this).val();
            var deptId = $("#enterDeptId").val();
            //查询城市
            $.ajax({
                type: "GET",
                url: prefix +'/product',
                async: false,
                data:{"deptId":deptId,"shopId":shopId},
                contentType : 'application/json;charset=utf-8',
                traditional:true,
                success : function(data) {
                    console.log(data)
                    $("#enterProductId").empty();
                    for(var i=0;i<data.length;i++){
                        var html = "<option value='"+data[i].id+"'>"+data[i].productName + "</opinion>"
                        $("#enterProductId").append(html);
                    }
                },
                error:function(e) {
                    console.info(e);
                }
            });
        });
		// 验证订单编号是否存在
        // $("#form-enter-edit").validate({
         //    onkeyup: false,
         //    rules:{
         //        formNum:{
         //            remote: {
         //                url: prefix + "/checkFormNum",
         //                type: "post",
         //                dataType: "json",
         //                data: {
         //                    "formNum" : function() {
         //                        return $.common.trim($("#formNum").val());
         //                    }
         //                },
         //                dataFilter: function(data, type) {
         //                    return $.validate.unique(data);
         //                }
         //            }
         //        },
         //    },
         //    messages: {
         //        "formNum": {
         //            remote: "该订单编号已经存在"
         //        },
         //    },
         //    focusCleanup: true
        // });


		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/editEnterForm", $('#form-enter-edit').serialize());
	        }
	    }


	    
	</script>
</body>
</html>
